/*
 *接口编写处...
*如果接口需要做Action的权限验证，请在Action上使用属性
*如: [ApiActionPermission("Quality_TestMaterial",Enums.ActionPermissionOptions.Search)]
 */
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using iMES.Entity.DomainModels;
using Yun.Quality.IServices;
using iMES.Core.Utilities;
using YUN.Rawmanagements.Services;
using iMES.Core.Enums;
using iMES.Core.Filters;

namespace Yun.Quality.Controllers
{
    //public partial class Quality_TestMaterialController
    //{
    //    private readonly IQuality_TestMaterialService _service;//访问业务代码
    //    private readonly IHttpContextAccessor _httpContextAccessor;

    //    [ActivatorUtilitiesConstructor]
    //    public Quality_TestMaterialController(
    //        IQuality_TestMaterialService service,
    //        IHttpContextAccessor httpContextAccessor
    //    )
    //    : base(service)
    //    {
    //        _service = service;
    //        _httpContextAccessor = httpContextAccessor;
    //    }
    //}
    public partial class Quality_TestMaterialController
    {
        private readonly IQuality_TestMaterialService _service;//访问业务代码
        private readonly IHttpContextAccessor _httpContextAccessor;

        [ActivatorUtilitiesConstructor]
        public Quality_TestMaterialController(
            IQuality_TestMaterialService service,
            IHttpContextAccessor httpContextAccessor
        )
        : base(service)
        {
            _service = service;
            _httpContextAccessor = httpContextAccessor;
        }

        WebResponseContent webResponse = new WebResponseContent();



        /// <summary>
        /// 获取table1的数据
        /// </summary>
        /// <param name="loadData"></param>
        /// <returns></returns>
        [Route("getTable1Data"), HttpPost, ApiActionPermission("Quality_TestMaterial", ActionPermissionOptions.Search)]
        public async Task<IActionResult> GetTable1Data([FromBody] PageDataOptions loadData)
        {
            return JsonNormal(await Service.GetTable1Data(loadData));
        }

        /// <summary>
        /// 获取table2的数据
        /// </summary>
        /// <param name="loadData"></param>
        /// <returns></returns>
        [Route("GetTable2Data"), HttpPost, ApiActionPermission("Quality_TestDetail", ActionPermissionOptions.Search)]
        public async Task<IActionResult> GetTable2Data([FromBody] PageDataOptions loadData)
        {
            return JsonNormal(await Service.GetTable1Data(loadData));
        }
        [HttpPost, Route("getSelectorPlan")]
        public IActionResult getSelectorPlan([FromBody] PageDataOptions options)
        {
            //1.可以直接调用框架的GetPageData查询
            PageGridData<Rawmanagement> data = Base_RawmanagementServies.Instance.GetPageData(options);
            return JsonNormal(data);
        }
    }

}
